<template>
  <div>
    <el-container style="height: 100vh; border: 1px solid #eee">
      <el-aside width="210px" style="background-color: rgb(48, 65, 86)">
        <div>
          <img
            src="http://www.mobiletrain.org/images/index/new_logo.png?t=5.28"
            style="background-size: 54px, 54px"
          />
        </div>
        <el-menu :default-openeds="['1', '3']" router>
          <el-menu-item index="/admin/user">用户管理</el-menu-item>
          <el-menu-item index="/admin/role">角色管理</el-menu-item>
        </el-menu>
      </el-aside>

      <el-container>
        <el-header style="text-align: right; font-size: 12px">
          <el-dropdown @command="dropdownFn">
            <i class="el-icon-setting" style="margin-right: 15px"></i>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item command="setting">个人中心</el-dropdown-item>
              <el-dropdown-item command="login">退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
          <span>臭皮匠</span>
        </el-header>

        <el-main>
          <!-- 子路由 -->
          <router-view />
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
export default {
  data() {
    const item = {
      date: "2021-05-25",
      name: "臭皮匠",
      address: "上海市普陀区金沙江路 1518 弄",
    };
    return {
      tableData: Array(20).fill(item),
    };
  },
  methods: {
    dropdownFn(arg) {
      if (arg === "setting") {
        this.$router.replace("/admin/setting").catch(() => {});
      }
      if (arg === "login") {
        this.$router.replace("/login").catch(() => {});
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.el-header {
  color: #333;
  line-height: 60px;
  box-shadow: 0 3px 5px 1px #e8e8e8;
}

.el-aside {
  color: #333;
  border-right: 1px solid #c1c6cb;
  box-shadow: 3px 0 8px 1px #c1c6cb;
  div {
    background: #ececec;
    img {
      display: block;
    }
  }
}
.el-menu {
  background-color: rgb(48, 65, 86);
  border: none;
  .el-menu-item {
    text-indent: 1em;
    color: #bfcbd9;
    &.is-active {
      color: #409eff;
    }
    &:focus,
    &:hover {
      background-color: #2d3d51;
    }
  }
}
</style>